package de.zinulla.moviethek.db;

import android.content.Context;
import android.database.Cursor;
import android.graphics.BitmapFactory;
import android.support.v4.widget.SimpleCursorAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

public class GridCursorAdapter extends SimpleCursorAdapter {

	private Context mContext;

	public GridCursorAdapter(Context context, int layout, Cursor c,
	        String[] from, int[] to) {
	    super(context, layout, c, from, to);
	    mContext = context;
	}
	
	@Override
    public void bindView(View view, Context context, Cursor cursor) {
        byte[] byteArr = cursor.getBlob(MovieDataSource.COLUMN_COVER);
        ImageView image = (ImageView) view;
		image.setImageBitmap(BitmapFactory.decodeByteArray(byteArr, 0, byteArr.length));
    }

@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
    View v = new ImageView(context);
    bindView(v, context, cursor);
    return v;
}

}
